package Protocols.Test;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

import Protocols.EnumClientRequests.Login;
import Protocols.EnumClientRequests.Logout;

public class TestClientZuVerwalten implements Runnable{
	
	TestServer SERVER;
	ObjectInputStream in;	
	ObjectOutputStream out;

	public TestClientZuVerwalten(Login login, TestServer testServer, ObjectInputStream newInput, ObjectOutputStream newOutput) {
		in =newInput;
		out =newOutput;
		SERVER=testServer;
	}

	public void run() {
		System.out.println("ServerClinet: is running");
		ServerListener listener= new ServerListener(SERVER,in,out);
		listener.start();
		while (true){
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		//hier w�rde der client verwaltet werden, bis er ein logout sendet
		
		/*while (true){
			Object o=null;
			try {
				o = in.readObject();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();return;
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if (o instanceof Logout){
				System.out.println("ServerClient: logging out");
				SERVER.logout((Logout)o, this);
				System.out.println("ServerClient: logged out");
				return;
			}
		}*/
	}

	public void sendMessage(String s) {
		try {
			out.writeObject(s);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
